package com.springtest.demo.serices.impl;

import com.springtest.demo.dao.TeacherDao;
import com.springtest.demo.model.ResultEntity;
import com.springtest.demo.model.Teacher;
import com.springtest.demo.serices.BaseService;
import com.springtest.demo.serices.TeacherService;

import javax.annotation.Resource;

import org.springframework.stereotype.Component;
import org.springframework.transaction.annotation.Transactional;

@Transactional
@Component("teacherService")
public class TeacherServiceImpl implements TeacherService{
	
	@Resource(name="teacherDao")
	private TeacherDao teacherDao;

	public ResultEntity save(Teacher t) {
		return ResultEntity.getInstance()
				.setData(teacherDao.save(t));
	}

	public ResultEntity update(Teacher t) {
		return ResultEntity.getInstance()
				.setData(teacherDao.update(t));
	}

	public ResultEntity delete(Teacher t) {
		return ResultEntity.getInstance()
				.setData(teacherDao.delete(t));
	}

	public ResultEntity delete(int id) {
		return ResultEntity.getInstance()
				.setData(teacherDao.delete(id));
	}

	public ResultEntity findById(int id) {
		return ResultEntity.getInstance()
				.setData(teacherDao.findById(id));
	}

	public ResultEntity findAll() {
		return ResultEntity.getInstance()
				.setData(teacherDao.findAll());
	}


}
